package com;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;

public class login extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("get");
        resp.setContentType("text/html;charset=utf-8");
        users users=new users(req.getParameter("username"),
                req.getParameter("password"),
                req.getParameter("email"));
        users.save();
        PrintWriter out=resp.getWriter();
        out.write(users.getUsername()+"注册成功！！");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("post");
        resp.setContentType("text/html;charset=utf-8");
        users users=new users(req.getParameter("username"),
                req.getParameter("password"),
                req.getParameter("email"));
        users.save();
        PrintWriter out=resp.getWriter();
        out.write(users.getUsername()+"注册成功！！");
    }
}
